﻿using DarkSKL_Core.MongoDBModules.Models;
using Microsoft.AspNetCore.Razor.TagHelpers;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;

namespace Dark_Core_Server.Models.Article
{
    /// <summary>
    /// 文章文档
    /// </summary>
    public class ArticleDocument : DocumentUnit
    {

        [BsonElement("UserId")]
        [BsonRepresentation(BsonType.ObjectId)]
        public ObjectId UserId { set; get; }

        [BsonElement("Title")]
        [BsonRepresentation(BsonType.String)]
        public string Title { set; get; }

        [BsonElement("PictureUrl")]
        [BsonRepresentation(BsonType.String)]
        public string PictureUrl { set; get; }

        [BsonElement("ThumbnailPictureUrl")]
        [BsonRepresentation(BsonType.String)]
        public string ThumbnailPictureUrl { set; get; }

        [BsonElement("Content")]
        [BsonRepresentation(BsonType.String)]
        public string Content { set; get; }

        [BsonElement("Synopsis")]
        [BsonRepresentation(BsonType.String)]
        public string Synopsis { set; get; }

        [BsonElement("Tags")]
        public string[] Tags { set; get; } = Array.Empty<string>();

        [BsonElement("ViewLevel")]
        [BsonRepresentation(BsonType.Int64)]
        public int ViewLevel { set; get; }

        [BsonElement("ReadCount")]
        [BsonRepresentation(BsonType.Int32)]
        public int ReadCount { set; get; } = 0;

        [BsonElement("FileIds")]
        public ObjectId[] FileIds { set; get; }

        public static ArticleDocument Empty => new ArticleDocument(){id = ObjectId.Empty};
    }
}
